/**
 * 
 */
package com.thor.palmmall.rest.patrol.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.patrol.ADeviceCategory;
import com.thor.palmmall.spi.basic.SDeviceCategory;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class ADeviceCategoryConverter implements Converter<SDeviceCategory, ADeviceCategory> {

  public static ADeviceCategoryConverter getInstance() {
    if (instance == null)
      instance = new ADeviceCategoryConverter();
    return instance;
  }

  private static ADeviceCategoryConverter instance;

  private ADeviceCategoryConverter() {
  }

  @Override
  public ADeviceCategory convert(SDeviceCategory source) {
    if (source == null) {
      return null;
    }
    ADeviceCategory target = new ADeviceCategory();
    target.setCategory(UCN.newInstance(source.getCategory()));
    target.setEnabled(source.getEnabled());
    target.setUpper(UCN.newInstance(source.getUpper()));
    return target;
  }

}
